package com.wn.service.impl;

import cn.hutool.crypto.digest.BCrypt;
import com.wn.mapper.UserMapper;
import com.wn.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Locale;

/**
 * @author yellow Docter
 * @date 2024-07-08
 * @desc 蜗牛创想：www.woniuxy.com
 */
@Service
public class UserServiceImpl implements IUserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public boolean login(String username, String password) {

        String pwd = userMapper.findUserByName(username);
        //密码比对
//        boolean flag = password.equals(pwd);
        //数据库存储的是加密后的 密码 需要用hutool工具来判断 加密的正确性
        boolean flag = BCrypt.checkpw(password,pwd);
        return flag;
    }

}
